package wstrader.task.warehouse.weighing;

import pc.system.*;

public class Export extends WN_IMEX
{
  public Export(Tasks owner)
  {
    //super(owner,"export","export-3",WN_EXPORT);
    super(owner,WN_EXPORT);
  }
/*
  public String getNew_WN()
  {
    return getNew_WN(getRequest().getLongValue("inst_id"));
  }

  public ResultSet getContract_List()
  {
    return this.getContract_List(' ');
  }
*/
/*
  public ResultSet getBroker_List()
  {
    return this.getBroker_List(' ');
  }
*/
/*
  public ResultSet getSI_List()
  {
    int buyer_id = getRequest().getIntValue("buyer_id");
    String sql =
        "SELECT si.id, si.ref_number AS name, si.status " +
        "FROM shipping_instruction di " +
        "LEFT JOIN contracts ct ON si.contract_id = ct.id " +
        "WHERE (ct.supplier_buyer_id = ? OR ?) ";
    Vector vp = new Vector();
    vp.addElement(new IntValue(buyer_id));
    vp.addElement(new BooleanValue(buyer_id == 0));
    return getSQLCommand().executeQuery(sql,vp);
  }
*/
  /*
  public ResultSet getWN_List()
  {
    int inst_id = getRequest().getIntValue("inst_id");
    String sql =
        "SELECT wn.id, wn.ref_number AS name, wn.status " +
        "FROM weight_note_im wn " +
        "WHERE wn.inst_id = " + inst_id + " " +
        "ORDER BY status, name DESC";
    return getSQLCommand().executeQuery(sql);
  }

  public Record getWN_Ref()
  {
    long wn_id   = getRequest().getLongValue("wn_id");
    long inst_id = getRequest().getLongValue("inst_id");
    String sql = "SELECT ";
    if (wn_id < 0) {
      sql +=
          "'" + getNew_WN() + "' AS ref_number, " +
          "      CURDATE() AS date, " +
          "      CURTIME() AS time, ";
    }
    sql +=
        "       ct.ref_number AS ct_ref_number," +
        "       ct.contract_no," +
        "       su.name AS supplier, " +
        "       og.name AS origin, " +
        "       qu.name AS quality, " +
        "       gr.name AS grade, " +
        "       pk.name AS packing, " +
        "       di.ref_number AS di_ref_number," +
        "       di.tons AS di_tons," +
        "       di.no_of_bags AS di_no_of_bags," +
        "       wn.* ";
    if (wn_id <= 0) {
      sql +=
          "FROM delivery_instruction di " +
          "LEFT JOIN weight_note_im wn  ON wn.id = 0 ";
    } else {
      sql +=
          "FROM weight_note_im wn " +
          "LEFT JOIN delivery_instruction di ON wn.inst_id     = di.id ";
    }
    sql +=
        "LEFT JOIN contracts      ct ON di.contract_id       = ct.id " +
        "LEFT JOIN packing_master pk ON di.packing_id        = pk.id " +
        "LEFT JOIN company_master su ON ct.supplier_buyer_id = su.id " +
        "LEFT JOIN origin_master  og ON ct.origin_id         = og.id " +
        "LEFT JOIN quality_master qu ON ct.quality_id        = qu.id " +
        "LEFT JOIN grade_master   gr ON ct.grade_id          = gr.id ";
    if (wn_id <= 0) {
      sql += "WHERE di.id = " + inst_id;
    }  else {
      sql += "WHERE wn.id = " + wn_id;
    }
    return new Record(getSQLCommand().executeQuery(sql));
  }

  public ResultSet getWNR_Detail()
  {
    String sql =
        "SELECT * FROM weight_note_ref WHERE wn_id = " + id;
    return getSQLCommand().executeQuery(sql);
  }
*/
  private void update_ContractAllocation()
  {
  }

  public long doTask()
  {
    id = super.doTask();
    if (isUpdated()) update_ContractAllocation();
    return id;
  }

}
